package com.similarworld.bean;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.similarworld.model.Item;
import com.similarworld.service.CategoryService;
import com.similarworld.service.ItemService;
import com.similarworld.util.JSFUtil;

@Component("itemBean")
@Scope("request")
public class ItemBean {

	private static final Logger logger = LoggerFactory.getLogger(ItemBean.class);

	@Autowired
	private CategoryService categoryService;
	
	@Autowired
	private ItemService itemService;
	
	private Item item;
	
	@PostConstruct
	public void init() {
		String itemId = JSFUtil.getRequestParameter("item_id");
		Long id = 0l;
		try {
			id = Long.parseLong(itemId);
			setItem(itemService.get(id));
		} catch (Exception e) {
		}
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}
	

}
